"use strict";
const app = new (require('koa'))();
const Router = require('koa-router');
const serve = require('koa-static-cache');
const logAdapter = new (require('koa-log4js-base'))('http2');
const bodyParser = require('koa-bodyparser');
const path = require('path');
const render = require('koa-art-template');

// 模板引擎
render(app, {
  root: path.join(__dirname, 'views'),
  extname: '.html',
  debug: true
});

app.use(logAdapter.adapt()); // 日志记录
app.use(serve('./public',{gzip:true})); // 静态资源
app.use(bodyParser()); // post 请求参数

// 路由
const appRouter = new Router();
appRouter.use('/http2', require('./routes/index').routes());
app.use(appRouter.routes()).use(appRouter.allowedMethods());

module.exports = app;
